package com.gz.bean;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ViewState {
	private String viewState;
	private String viewStateGenerator;
	public String getViewState() {
		return viewState;
	}
	public void setViewState(String viewState) {
		this.viewState = viewState;
	}
	public String getViewStateGenerator() {
		return viewStateGenerator;
	}
	public void setViewStateGenerator(String viewStateGenerator) {
		this.viewStateGenerator = viewStateGenerator;
	}
	public static String filterViewState(String content) {
		String viewState = "";
		String reg = "__VIEWSTATE\" value=\"(.*?)\" />";
	    Pattern pattern = Pattern.compile(reg);
	    Matcher matcher = pattern.matcher(content);
	    while(matcher.find()){
	    	viewState = matcher.group(1);
        }
//	    System.out.println(viewState);
		return viewState;
	}
	public static String filterViewStateGenerator(String content) {
		String viewState = "";
		String reg = "__VIEWSTATEGENERATOR\" value=\"(.*?)\" />";
	    Pattern pattern = Pattern.compile(reg);
	    Matcher matcher = pattern.matcher(content);
	    while(matcher.find()){
	    	viewState = matcher.group(1);
        }
//	    System.out.println(viewState);
		return viewState;
	}
	public static void main(String[] args) {
		String temp = "<input type=\"hidden\" name=\"__VIEWSTATEGENERATOR\" id=\"__VIEWSTATEGENERATOR\" value=\"41363C13\" />";
		filterViewStateGenerator(temp);
	}
}
